#!/bin/fish
echo 获取权限成功
cat ~/.config.txt | tail -n +1 | head -n 1 | read AppimageName
cat ~/.config.txt | tail -n +2 | head -n 1 | read Path
cat ~/.config.txt | tail -n +3 | head -n 1 | read Name
cat ~/.config.txt | tail -n +4 | head -n 1 | read Version
cat ~/.config.txt | tail -n +5 | head -n 1 | read Size
# echo 输入AppImage文件路径（绝对路经,不带文件名）：
#read Path
# echo 输入程序名：
# read Name
# echo 输入Appimage文件名称（例:xxx.appimage）：
# read AppimageName
# echo 输入deb包版本：
# read Version
echo 开始打包：
set buildDir ~/a2d/$Name
mkdir ~/a2d/
mkdir $buildDir
cd $Path
eval ./$AppimageName --appimage-extract
mv squashfs-root/ $buildDir
cp $AppimageName $buildDir
cd $buildDir
mkdir deb
mkdir deb/opt/
mkdir deb/opt/durapps
cp $AppimageName deb/opt/durapps/
mkdir deb/usr/
mkdir deb/usr/share
mkdir deb/usr/share/applications/ deb/usr/share/icons
mkdir deb/DEBIAN
mv squashfs-root/*.desktop deb/usr/share/applications
mv squashfs-root/usr/share/icons/* deb/usr/share/icons/
cd deb/usr/share/applications
mkdir a/
sed -e '/AppRun/d' *.desktop > a/$Name.desktop
echo Exec=/opt/durapps/$AppimageName >> a/$Name.desktop
rm -rf *.desktop
mv a/$Name.desktop ./
rm -rf a/
cd $buildDir
cd deb/DEBIAN/
touch control
chmod 775 control
echo Package:$Name >> control
echo Version:$Version >> control
echo Section:utils >> control
echo Priority:optional >> control
echo Architecture:amd64 >> control
echo Essential:no >> control
echo Depends: >> control
echo Recommends: >> control
echo Suggests: >> control
echo Maintainer:DCS[http://http://www.shenmo.tech:420] >> control
echo Conflicts: >> control
echo Replaces: >> control
echo Installed-Size:$Size >> control
echo Description:An application repacked by DCS Project. >> control
echo -e >> control
cat control
sleep 1
cd $buildDir
fakeroot dpkg -b deb $Name-$Version.deb
mv $Name-$Version.deb ~/
echo 包名：$Name-$Version.deb
rm -rf ~/a2d/$Name
echo 打包完成，存放在您的主目录。






